package leetCode.fourthWeek;

import java.util.LinkedList;
import java.util.List;

public class Code_73 {
  public void setZeroes(int[][] matrix) {
    List<Integer> line = new LinkedList<>();
    List<Integer> row = new LinkedList<>();
    for (int i = 0; i < matrix.length; i++) {
      for (int j = 0; j < matrix[i].length; j++) {
        if (matrix[i][j] == 0) {
          if (!line.contains(i)) {
            line.add(i);
          }
          if (!row.contains(j)) {
            row.add(j);
          }
        }
      }
    }
    for (int i = 0; i < matrix.length; i++) {
      for (int j = 0; j < matrix[i].length; j++) {
        if (line.contains(i) | row.contains(j)) {
          matrix[i][j] = 0;
        }
      }
    }
  }
}
